package com.itheima.test;

public class test5 {
    public static void main(String[] args) {
        int[] arr = {11,22,33,44,55};
        //调用方法遍历数组
        printArray(arr);
    }

    //定义方法用于数组遍历
    public static void printArray(int[] array){
        System.out.print("[");
        for (int i = 0; i < array.length; i++) {
            if(i == array.length-1){
                System.out.print(array[i]);
            }else{
                System.out.print(array[i]+",");
            }
        }
        System.out.println("]");
    }
}
